/**
 * 
 */
package com.nd.android.u.ui.activity.message_chat;

import android.annotation.TargetApi;
import android.os.Build;

import com.common.android.utils.task.genericTask.GenericTask;
import com.common.android.utils.task.genericTask.TaskParams;
import com.common.widget.CommonTipDlg.OnCommonDlgClickListener;
import com.nd.android.u.controller.innerInterface.IMessageDisplay;
import com.nd.android.u.ui.chatInterfaceImpl.DeleteChatRecordTask;
import com.nd.android.u.ui.chatUiUtils.AudioQuenePlayManager;

/**
 * 清除消息记录回调
 * <br>Created 2014-12-19 下午7:49:45
 * @version  
 * @author   ChuXY		
 *
 * @see 	 
 */
public class ClearMessageHistroyCallBack implements OnCommonDlgClickListener  {

	//删除记录回调
	private DeleteChatRecordTask mDeleteTask;
	//删除记录监听
	private DelChatRecordTaskListener mListener;
	
	/**消息*/
	private IMessageDisplay mMessage;
	
	public ClearMessageHistroyCallBack( DelChatRecordTaskListener listener,IMessageDisplay message){
		mListener=listener;
		mMessage=message;
	}
	@Override
	public void onLeftBtnClicked() {
		
	}

	@Override
	public void onRightBtnClicked() {
		AudioQuenePlayManager.getInstance().stopPlayAndSetCureentNull();
		deleteChatRecord();
	}

	/**
	 * 删除聊天记录
	 * <br>Created 2014-7-25 下午5:46:13
	 * @author       cb
	*/
	@TargetApi(Build.VERSION_CODES.CUPCAKE)
	private void deleteChatRecord() {
		if (mDeleteTask != null && mDeleteTask.getStatus() == GenericTask.Status.RUNNING) {
			return;
		} else {
			if(mListener==null){
				return;
			}
			mDeleteTask = new DeleteChatRecordTask(mMessage);
			mDeleteTask.setListener(mListener);
			TaskParams params = new TaskParams();
			mDeleteTask.execute(params);
		}
	}
}
